package com.ciwong.epaper.modules.me.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewGroup;

import com.jude.rollviewpager.RollPagerView;

/**
 * Created by dylan on 2016/11/1.
 */
public class ScoViewPager extends RollPagerView{


    private ViewGroup parent;


    public ScoViewPager(Context context){
        this(context,null);
    }

    public ScoViewPager(Context context, AttributeSet attrs) {
        this(context, attrs, 0);

    }
    public ScoViewPager(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void setNestParent(ViewGroup parent) {
        this.parent = parent;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        int action = ev.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
//                stopPlay();
                if (getParent() != null)
                    getParent().requestDisallowInterceptTouchEvent(true);

                break;
            case MotionEvent.ACTION_CANCEL:
//                startAutoPlay();
                if (getParent() != null)
                    getParent().requestDisallowInterceptTouchEvent(false);
                break;

            default:
                break;
        }
        return super.dispatchTouchEvent(ev);
    }


}
